package com.netease.nie.facade;

import java.util.Collections;
import java.util.List;

import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.base.cache.redis.Redis;
import com.netease.nie.dto.HorseRaceLampDto;

@Service
public class HorseRaceLampFacadeImpl implements HorseRaceLampFacade {

	private static final String HORSE_RACE_LAMP_LIST = "Horse_Race_Lamp_List";
	
	@Autowired
	private Redis redis;

	public List<HorseRaceLampDto> queryHorseRaceLampDtos() {
		boolean exists = redis.exists(HORSE_RACE_LAMP_LIST);
		if (exists) {
			List<HorseRaceLampDto> horseRaceLampDtoList = redis.lrange(HORSE_RACE_LAMP_LIST, 0, -1, HorseRaceLampDto.class);
			if (CollectionUtils.isNotEmpty(horseRaceLampDtoList))
				return horseRaceLampDtoList;
		}
		return Collections.emptyList();
	}
}
